<?php

class App_Methods_Request_GetUserPulpitApp {

  /**
   *
   * @var App_Methods_Data_App
   */
  public $app;
  public $applicationId;

  public function __construct($params) {
    $this->app = new App_Methods_Data_App($params->app);
    $this->applicationId = $params->applicationId;
  }

  public function process() {
    $userPulpit = UserPulpitQuery::create()->findPk(array(Core_Auth::getInstance()->getUser()->getId(), $this->applicationId));
    if (!$userPulpit instanceof UserPulpit) {
    	$userPulpit = new UserPulpit();
    	$userPulpit->setDefaultData();
    	$userPulpit->save();
    }
    $responseUserPulpit = new App_Methods_Data_UserPulpit($userPulpit);
    return new App_Methods_Response_GetUserPulpitApp(true, $responseUserPulpit);
  }

}